<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 

?>

<style type="text/css">
#mw_mobile .board_top { clear:both; height:30px; border-bottom:1px solid #ddd; }
#mw_mobile .board_list {
    list-style:none;
    margin:5px;
    padding:0;
    box-shadow: 0 1px #EBEBEB;
    border-radius: 3px;
    border: 1px solid;
    border-color: #E5E5E5 #D3D3D3 #B9C1C6;
    background-color:#fff;
}
#mw_mobile .board_list li.subject { list-style:none; border-bottom:1px solid #ddd; }
#mw_mobile .board_list li.subject a { font-size:15px; display:block; padding:5px 0 5px 5px; }
#mw_mobile .board_list li.subject div { margin:0 0 5px 0; }
#mw_mobile .board_list .notice { font:bold 1em tahoma; color:#006699; } 
#mw_mobile .board_list_none  { padding:50px 0 50px 0; text-align:center; border-bottom:1px solid #ddd; }

#mw_mobile .board_list { border-bottom:1px solid #ddd; } 
#mw_mobile .board_list { font-size:1em;  } 
#mw_mobile .board_list .num { color:#999999; text-align:center; }
#mw_mobile .board_list .checkbox { text-align:center; }
#mw_mobile .board_list .name { overflow:hidden; padding:0 0 0 5px; font-size:12px; }
#mw_mobile .board_list .datetime { font:normal 11px tahoma; color:#aaa; padding:0 0 0 5px; }
#mw_mobile .board_list .comment { font-family:Tahoma; font-size:11px; color:#EE5A00; }

#mw_mobile .board_button { clear:both; margin:10px 0 0 0; }

#mw_mobile .board_page { clear:both; text-align:center; margin:3px 0 0 0; font-size:15px; }
#mw_mobile .board_page { margin:30px 0 30px 0;  }
#mw_mobile .board_page a:link,
#mw_mobile .board_page a:visited,
#mw_mobile .board_page a:active,
#mw_mobile .board_page a:hover { font-size:15px; color:#777; border:1px solid #ddd; padding:5px; }
#mw_mobile .board_page a:hover { background-color:#efefef; }

#mw_mobile .board_search { text-align:center; margin:10px 0 0 0; }
#mw_mobile .board_search .stx { height:21px; border:1px solid #9A9A9A; border-right:1px solid #D8D8D8; border-bottom:1px solid #D8D8D8; }
</style>

<!-- 분류 셀렉트 박스, 게시물 몇건, 관리자화면 링크 -->
<div class="board_top">
    <div style="float:left;">
        <form name="fcategory" method="get" style="margin:0px;">
        <? if ($is_category) { ?>
        <select name=sca onchange="location='<?=$category_location?>'+this.value;">
        <option value=''>전체</option>
        <?=$category_option?>
        </select>
        <? } ?>
        </form>
    </div>
    <div style="float:right;">
        <span id="notice_view">[공지감춤]</span>
        <img src="<?=$new_skin_path?>/img/icon_total.gif" align="absmiddle" border='0'>
        <span style="color:#888; font-weight:bold;"><?=$page?>/<?=number_format($total_page)?> PAGE</span>
    </div>
</div>

<script>
if (get_cookie("mobile_notice_toggle_<?=$bo_table?>")) {
    var sheet = document.createElement('style')
    sheet.innerHTML = "#notice_line { display:none; }";
    document.body.appendChild(sheet);
    $("#notice_view").text("[공지보기]");
}
$("#notice_view").css("cursor", "pointer");
$("#notice_view").css("color", "#888");

$("#notice_view").click(function () {
    $("#notice_line").toggle(function () {
        if ($(this).css("display") != "none") {
            set_cookie("mobile_notice_toggle_<?=$bo_table?>", "", 0, g4_cookie_domain);
            $("#notice_view").text("[공지감춤]");
        }
        else {
            set_cookie("mobile_notice_toggle_<?=$bo_table?>", "1", 720, g4_cookie_domain);
            $("#notice_view").text("[공지보기]");
        }
    });
});
</script>

<!-- 제목 -->
<form name="fboardlist" method="post">
<input type='hidden' name='bo_table' value='<?=$bo_table?>'>
<input type='hidden' name='sfl'  value='<?=$sfl?>'>
<input type='hidden' name='stx'  value='<?=$stx?>'>
<input type='hidden' name='spt'  value='<?=$spt?>'>
<input type='hidden' name='page' value='<?=$page?>'>
<input type='hidden' name='sw'   value=''>

<ul class="board_list">
<?  for ($i=0; $i<count($list); $i++) { ?>
<?
//$list[$i][href] = mw_mobile_seo_url($list[$i][bo_table], $list[$i][wr_id], $qstr);
//$list[$i][href] = "board.php?bo_table={$list[$i][bo_table]}&wr_id={$list[$i][wr_id]}" . $qstr;


// 링크수정
for ($j=1; $j<=$g4[link_count]; $j++) {
    if ($list[$i][link][$j]) {
        $list[$i][link_href][$j] = "$mw_mobile[path]/link.php?bo_table=$bo_table&wr_id={$list[$i][wr_id]}&no=$j";
    }
}

// 댓글감춤
if ($list[$i][wr_comment_hide])
    $list[$i][comment_cnt] = 0;

if ($list[$i][comment_cnt])
    $list[$i][comment_cnt] = '('.$list[$i][comment_cnt].')';

// 자동치환
//$list[$i][subject] = mw_reg_str($list[$i][subject]);

// BC코드
//$list[$i][subject] = bc_code($list[$i][subject], 0);

// 익명
if ($list[$i][wr_anonymous]) {
    $list[$i][name] = "익명";
    $list[$i][wr_name] = $list[$i][name];
}

$write_icon =  "<img src=\"$new_skin_path/img/icon_subject.gif\" align=absmiddle style=\"border-bottom:2px solid #fff;\" width=13 height=12>&nbsp;";

$gr_subject = cut_str($list[$i][gr_subject], 10);
$bo_subject = cut_str($list[$i][bo_subject], 10);
$wr_subject = get_text(cut_str($list[$i][wr_subject], 40));


// sns식 날짜표시
//$list[$i][datetime2] = date("Y.m.d H:i", strtotime($list[$i][wr_datetime]));
//$list[$i][datetime2] = mw_basic_sns_date($list[$i][wr_datetime]);

if ($i == 0) {
    $notice_count = 0;
    if ($list[$i][is_notice]) {
        echo "<div id='notice_line'>";
        $notice_line = false;
        $notice_count++;
    }
}
if (!$notice_line && !$list[$i][is_notice] && $notice_count) {
    echo "</div> <!--notice_line-->";
    $notice_line = true;
}
?>

<li class="subject">
    <? 
    echo "<a href=\"{$list[$i][href]}\">";
    echo "<div>";

    echo $write_icon;
    echo $list[$i][reply];
    echo $list[$i][icon_reply];
    if ($is_category && $list[$i][ca_name])
        echo "[{$list[$i][ca_name]}] ";

    if ($list[$i][comment])
        $list[$i][wr_subject] = $list[$i][comment] . $list[$i][wr_subject];

    if ($list[$i][is_notice])
        echo "<span class='notice'>{$list[$i][wr_subject]}</span>";
    else
        echo "<span{$style}>{$list[$i][wr_subject]}</span>";
    ?>
    </div>
    <div>
        <span class="name"> <?=$list[$i][gr_subject]?> > <?=$list[$i][bo_subject]?> </span>
        <? if (!$list[$i][comment] && $list[$i][wr_comment]) { ?> <span class="comment">댓글 <?=$list[$i][comment_cnt]?></span> <? } ?>
        <span class="name"> by <?=$list[$i][wr_name]?> </span>
        <span class="datetime"> <?=$list[$i][datetime2]?> </span>
    </div>
    <?
    echo "</a>";
    ?>
</li>
<? } // end for ?>
</ul>

<? if (count($list) == 0) { ?> 
    <div class="board_list_none">게시물이 없습니다.</div>
<? } ?>

</form>

<div class="board_page">
    <input type="button" value="이전페이지" class="btn btn-default btn-sm"
        onclick="location.href='<?="$_SERVER[PHP_SELF]?view=$view&page=".($page-1)?>'" <? if ($page==1) echo "disabled";?>>
    <input type="button" value="다음페이지" class="btn btn-default btn-sm"
        onclick="location.href='<?="$_SERVER[PHP_SELF]?view=$view&page=".($page+1)?>'" <? if ($page>=$total_page) echo "disabled";?>>
</div>


